package com.tjsinfo.tjsoa.system.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.json.JSONArray;
import org.json.JSONObject;

import com.tjsinfo.tjsoa.system.bo.ILianDongBO;
import com.tjsinfo.tjsoa.system.vo.LianDong;

/**
 * 职位树
 * @author Administrator
 *
 */
public class LiandongTreeAction extends Action{
	private ILianDongBO lianDongBO;
	

	public ILianDongBO getLianDongBO() {
		return lianDongBO;
	}


	public void setLianDongBO(ILianDongBO lianDongBO) {
		this.lianDongBO = lianDongBO;
	}

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		List<LianDong> liandonglist = lianDongBO.selectAllLianDong();
		JSONArray array = new JSONArray();
		for (LianDong liandong : liandonglist) {
			JSONObject object = new JSONObject();
			object.put("id", liandong.getId());
			object.put("text", liandong.getLianDongLable());
			object.put("leaf", true);
			array.put(object);
		}
		response.getWriter().print(array);
		return null;
	}
	
}
